/*

Author   : chaos

FileName : stl_alg_find.cpp

Date     : 17/08/17 14:47:12

*/
#include <iostream>
#include <iterator>
#include <algorithm>
#include <vector>
using namespace std;

template< class T>

void print(vector<T> & pri_con)
{
    if(pri_con.empty())
        cout << "Container is empty!" << endl;
    else{
        typename vector<T>::iterator i;

        for(i = pri_con.begin() ; i != pri_con.end(); i++)
        {
            cout << *i << " ";
            cout << endl;
        }
    }
}

int main(int argc ,char *argv[])
{

    char a[] = {'B','G','C','E','G'};
    vector<char> v1(a,a+5) ,v2(a+2,a+3);
    vector<char>::iterator iter;
    cout << " v1 : ";
    print(v1);

    iter = find(v1.begin(),v1.end(),'G');

    if(iter == v1.end())
        cout << "'G' is in container!" << endl;

    cout << "v1 : " ;
    print(v1);

    cout << "v2 : ";
    print(v2);
    iter = search(v1.begin() , v1.end(),v2.begin(),v2.end());

    if (iter == v1.end())
        cout << "'GC' is not in container !" << endl;
    else
        cout << "'GC' is in container !" << endl;

    cout << "v1 : " ;
    print(v1);
    cout << "V2 :" ;
    print(v2);

    iter = search(v1.begin(),v1.end(),v2.begin(),v2.end());

    if(iter == v1.end())
        cout << "'GC' is not in container!" << endl;
    else
        cout << "'GC' is in container !" << endl;
    return 0;
}
